package io.finer.erp.jeecg.purchase.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.finer.erp.jeecg.purchase.entity.PurchaseSettings;
import io.finer.erp.jeecg.purchase.service.PurchaseSettingsService;
import io.finer.erp.jeecg.purchase.vo.PurchaseRequestPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 采购通用设置 前端控制器
 * </p>
 *
 * @author yaoyifan
 * @since 2021-06-04
 */
@Api(tags="采购通用配置")
@RestController
@RequestMapping("/purchase/purchaseSettings")
@Slf4j
public class PurchaseSettingsController {

    @Autowired
    PurchaseSettingsService purchaseSettingsService;

    @AutoLog(value="通用配置查询")
    @ApiOperation(value="通用配置查询", notes = "通用配置查询")
    @GetMapping()
    public Result<?> get(){
        PurchaseSettings ps = purchaseSettingsService.getOne(new QueryWrapper<PurchaseSettings>());
        return Result.ok(ps);
    }

    @AutoLog(value="通用配置修改")
    @ApiOperation(value="通用配置修改", notes = "通用配置修改")
    @PutMapping()
    public Result<?> edit(@RequestBody PurchaseSettings purchaseSettings) {
        purchaseSettingsService.updateById(purchaseSettings);
        return Result.ok("编辑成功!");
    }
}

